package model.factories.commandable;

import java.util.Map;
import java.util.Scanner;
import java.util.regex.Pattern;
import model.Interpreter;
import model.SyntaxErrorException;
import model.commands.Command;
import model.commands.commandable.TowardsCommand;
import model.factories.CommandFactory;


/**
 * A factory used to build TowardsCommand objects.
 * 
 * @author Erick Gonzalez
 * @author JLongley
 */
public class TowardsCommandFactory extends CommandFactory {
    
    private static final int NUM_ARGS = 2;
    private final Pattern myTowardsPattern = Pattern.
            compile(getInterpreter().getLanguage().getString("TowardsCommandPattern"));
    

    /**
     * 
     * @param interpreter an Interpreter
     */
    public TowardsCommandFactory (Interpreter interpreter) {
        super(interpreter);
    }

    @Override
    public Command createCommand (Scanner commandReader,
                                  Map<String, Integer> variables) throws SyntaxErrorException {
        return createKnownArgsCommand(commandReader,
                                      new TowardsCommand(), NUM_ARGS,
                                      variables);
    }

    @Override
    public Pattern patternToMatch () {
        return myTowardsPattern;
    }

}
